package com.conversationboard.model.exceptions;

public class UserAlreadyExistsException extends Exception {

    private static final long serialVersionUID = -3972991165297980607L;
    private String loginId = null;
    private String displayName = null;


    public String getLoginId() {
        return loginId;
    }


    public void setLoginId(String loginId) {
        this.loginId = loginId;
    }


    public UserAlreadyExistsException() {
        super();
    }


    /**
     * Don't expect users to already exist.
     * 
     * @param userId pass in NULL if this isn't a duplicate
     * @param displayName pass in NULL if this isn't a duplicate
     */

    public UserAlreadyExistsException(String userId, String displayName) {
        super(userId);
        this.loginId = userId;
        this.displayName = displayName;
    }


    public UserAlreadyExistsException(String arg0, Throwable arg1) {
        super(arg0, arg1);
    }


    public UserAlreadyExistsException(Throwable arg0) {
        super(arg0);
    }


    public String getDisplayName() {
        return displayName;
    }


    public void setDisplayName(String displayName) {
        this.displayName = displayName;
    }


    public String getMessage() {

        if (this.loginId != null && this.displayName != null) {
            return "Both the login ID: " + this.loginId + " and the display name: " + this.displayName + " already exist." + " Please choose different IDs.";
        } else if (this.loginId == null) {
            return "The display name: " + this.displayName + " has already been chosen, please choose another.";
        } else if (this.displayName == null) {
            return "The login ID: " + this.loginId + " has already been chosen, please choose another.";
        }

        throw new IllegalStateException("Should never reach here");
    }

}
